import pandas as pd
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

from utils import find_element_click, find_element_input



# 后续操作 pandas openyxl，xlrd，，操作excel
# 读取excel数据源
df = pd.read_excel("2019年土坪厕改花名册最终版.xlsx")
for idx, row in df.iterrows():
    身份证号码 = row["身份证号码"]
    print(身份证号码)
    try:
        # Selenium问题-无法定位元素：{"method":"css selector"，"selector“-需要帮助解决此问题
        # 出现无法定位元素时使用原始写法可得到错误提示：driver.find_element(By.ID, "")
        # 参考网址https://cloud.tencent.com/developer/ask/sof/1221860
        find_element_input(driver, By.ID, "certificatesNo", 身份证号码)
    except Exception as e:
        print("等了10秒没有找到相应元素链接，无法输入，错误：", e)
        # print(idx)
    find_element_click(driver, By.CSS_SELECTOR, "button[type='submit']")
    find_element_click(driver, By.CSS_SELECTOR, "a[title='编辑']")